<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
  <!ENTITY xhtml "http://www.w3.org/1999/xhtml">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:a="&a;"
  exclude-result-prefixes="xsl l a"
>
  <xsl:output method="xml" encoding="iso-8859-1" indent="yes"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    media-type="application/xhtml+xml"/>
  
  <xsl:variable name="a:current-mime-type" select="'application/xhtml+xml'"/>
    
  <xsl:template match="/" name="a:html-page">
    <!-- So, we need to do this in two steps ?? -->
    <xsl:variable name="output-rtf">
      <html xml:lang='{$a:locale}'>
        <xsl:call-template name="a:html-content"/>
      </html>
    </xsl:variable>
    <xsl:apply-templates select="exslt:node-set($output-rtf)/*" mode="xhtml-format"/>
  </xsl:template>
  
  <xsl:template match="*" mode="xhtml-format">
    <xsl:element name="{local-name()}" namespace="&xhtml;">
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates mode="xhtml-format"/>
    </xsl:element>
  </xsl:template>
  
  <xsl:template name="a:lang-attr">
    <xsl:param name="lang" select="string(@xml:lang)"/>
    <xsl:if test="$lang">
      <xsl:attribute name="xml:lang">
        <xsl:value-of select="$lang"/>
      </xsl:attribute>
    </xsl:if>
  </xsl:template>
  
  <!-- xsl:template match="*[contains(@class,'spacer')]" mode="xhtml-format">
    <xsl:element name="{local-name()}" namespace="&xhtml;">
      <xsl:copy-of select="@*"/>
      <xsl:text>&#160;</xsl:text>
    </xsl:element>
  </xsl:template -->
  
  <xsl:template match="l:stylesheet[@ie-only]" mode="a:head-stylesheet">
    <!-- this is an ie hack, suited for HTML 4.01
         if XHTML, must use proper xml syntax -->
    <xsl:comment>[if lt IE 7]>
      &lt;link rel="<xsl:value-of select="@rel"/>" type="<xsl:value-of select="@imt"/>" href="<xsl:value-of select="a:format-stylesheet-path(a:public-static-url(@uri))"/>"/&gt;
    &lt;![endif]</xsl:comment>
  </xsl:template>
  
</xsl:stylesheet>

